﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 平交口设计.solid;
using 平交口设计;
using CheccCoverplateCulvertAssemble.Common.Total;
using CheccCoverplateCulvertAssemble.Conmmon;
using CheccTexturePropertyGive;

namespace Checc_CircularCulvert_Assemble.structures.aliform
{
    public class AliformLeftStructures
    {
        private readonly AliformWallBase aliformWallBase;
        private readonly DgnModel dgnModel;
        private readonly double sideSlope;
        private readonly Angle angle;
        private readonly double clearHeight;
        private readonly double coverplateThickness;
        private readonly double culvertWidth;
        private readonly double endWallExceedheight;
        private readonly string solidName;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="aliformWallBase">八字墙界面对象</param>
        /// <param name="solidName">例如:圆管涵</param>
        /// <param name="dgnModel">模型</param>()
        /// <param name="sideSlope">路基边坡</param>
        /// <param name="angle">边坡线和涵洞线夹角</param>
        /// <param name="clearHeight">净高(单位米)</param>
        /// <param name="coverplateThickness">盖板厚(单位米)</param>
        /// <param name="culvertWidth">涵洞宽度(单位米)</param>
        /// <param name="endWallExceedheight">端墙超出高度(单位米)</param>
        public AliformLeftStructures(AliformWallBase aliformWallBase, string solidName, DgnModel dgnModel, double sideSlope, Angle angle, double clearHeight, double coverplateThickness, double culvertWidth, double endWallExceedheight)
        {
            this.aliformWallBase = aliformWallBase;
            this.dgnModel = dgnModel;
            this.sideSlope = sideSlope;
            this.angle = angle;
            this.clearHeight = clearHeight;
            this.coverplateThickness = coverplateThickness;
            this.culvertWidth = culvertWidth;
            this.endWallExceedheight = endWallExceedheight;
            this.solidName = solidName;
        }

        /// <summary>
        /// 创建端墙模型
        /// </summary>
        /// <returns>八字墙模型</returns>
        public List<Element> CreateAliformModel()
        {
            CheccWingWallData WingWallData = CheccWingWallData.Instance;
            //WingWallData.angle_Lmax = 45;
            //WingWallData.angle_Rmax = 35;
            //WingWallData.angle_Lmin = 25;
            //WingWallData.angle_Rmin = 15;
            WingWallData.solidName = this.solidName;
            WingWallData.slope_subgrade = this.sideSlope;
            WingWallData.thickness_pave = this.aliformWallBase.PaveThickness * 0.01;
            WingWallData.paveOffset_L = this.aliformWallBase.PavelLengthen * 0.01;
            WingWallData.H_CutoffWall = this.aliformWallBase.CutoffWallHeight * 0.01;//需要不含铺砌高度
            WingWallData.angle_Lmin = this.angle.Degrees < 90 ? this.aliformWallBase.ObeyAngle : this.aliformWallBase.ContraryAngle;//左洞小桩号
            WingWallData.angle_Lmax = this.angle.Degrees < 90 ? this.aliformWallBase.ContraryAngle : this.aliformWallBase.ObeyAngle;//左洞大桩号
            WingWallData.W_topWall = this.aliformWallBase.VeticalWidth * 0.01; //八字墙顶宽a
            WingWallData.H_min = this.aliformWallBase.MinCrossProfileHeight * 0.01;//八字墙最低截面高度h
            WingWallData.H_max = this.clearHeight + this.coverplateThickness + this.endWallExceedheight + this.aliformWallBase.BurialDepth * 0.01 - this.aliformWallBase.BaseThickness * 0.01;//净高+盖板厚+一字墙超出高度+（基础入土深度h-翼墙基础厚度d）
            WingWallData.W_innerEdge = this.aliformWallBase.InsideEdge * 0.01;//基础内侧襟边e1
            WingWallData.W_outerEdge = this.aliformWallBase.OutSideEdge * 0.01;//基础外侧襟边e2
            WingWallData.slope_outerVerticalWall = this.aliformWallBase.VerticalBackSlope;//翼墙垂直背坡(n:1)
            WingWallData.foundationThickness = this.aliformWallBase.BaseThickness * 0.01;//翼墙基础厚度d
            WingWallData.A_L = this.angle.Degrees;
            WingWallData.paveSlope_L = this.aliformWallBase.EntranceCaveSlope;//铺砌坡度
            WingWallData.W_CutoffWall = this.aliformWallBase.CutoffWallThickness * 0.01;//截水墙厚
            WingWallData.paveZ_L = 0;//左洞洞口铺砌基点高程(高于八字墙底面的高度)
            //计算八字墙净距
            double cleardistance = (this.culvertWidth + 2 * this.aliformWallBase.CulvertInEdge * 0.01) / Math.Sin(this.angle.Degrees / 180 * Math.PI);
            WingWallData.distance_L = cleardistance;// 左洞两侧八字墙最高截面处沿桩号的净距 


            CheccWingWall.Create(dgnModel, this.endWallExceedheight + this.aliformWallBase.BurialDepth * 0.01 - this.aliformWallBase.BaseThickness * 0.01);
            //CheccWingWall.AliformAddModels(this.solidName, true);
            List<Element> elements = new List<Element>
            {
                CheccWingWall.wingWall_L.Item1,
                CheccWingWall.wingWall_L.Item2,
                CheccWingWall.wingWall_L.Item3,
                CheccWingWall.wingWall_L.Item4,
                CheccWingWall.wingWall_L.Item5,
                CheccWingWall.wingWall_L.Item6
            };

            CheccCoverplateCulvertAssemble.FormColl.Assemble.SetTableData("八字墙", "墙身", GeneralHelpers.GetCSVDatas("八字墙")["八字墙材料"], SetCoverCulvertECProperty.GetVolume(CheccWingWall.wingWall_L.Item1, Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp), "m³");
            CheccCoverplateCulvertAssemble.FormColl.Assemble.SetTableData("八字墙", "墙身", GeneralHelpers.GetCSVDatas("八字墙")["八字墙材料"], SetCoverCulvertECProperty.GetVolume(CheccWingWall.wingWall_L.Item5, Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp), "m³");

            CheccCoverplateCulvertAssemble.FormColl.Assemble.SetTableData("八字墙", "基础", GeneralHelpers.GetCSVDatas("八字墙")["八字墙基础材料"], SetCoverCulvertECProperty.GetVolume(CheccWingWall.wingWall_L.Item2, Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp), "m³");
            CheccCoverplateCulvertAssemble.FormColl.Assemble.SetTableData("八字墙", "基础", GeneralHelpers.GetCSVDatas("八字墙")["八字墙基础材料"], SetCoverCulvertECProperty.GetVolume(CheccWingWall.wingWall_L.Item6, Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp), "m³");

            CheccCoverplateCulvertAssemble.FormColl.Assemble.SetTableData("八字墙", "隔水墙铺底", GeneralHelpers.GetCSVDatas("铺砌")["混凝土等级"], SetCoverCulvertECProperty.GetVolume(CheccWingWall.wingWall_L.Item3, Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp), "m³");
            CheccCoverplateCulvertAssemble.FormColl.Assemble.SetTableData("八字墙", "隔水墙铺底", GeneralHelpers.GetCSVDatas("截水墙")["混凝土等级"], SetCoverCulvertECProperty.GetVolume(CheccWingWall.wingWall_L.Item3, Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp), "m³");

            return elements;
        }

        public void AliformModelAddMaterial(List<Element> elements)
        {

        }

    }
}



